//
// Created by admin on 2021/4/29.
//

#ifndef TESTFREETYPE_TEXT_SHADER_H
#define TESTFREETYPE_TEXT_SHADER_H

#include <texture-font.h>
#include "shader_base.h"
#include <ctype.h>
#include "text_bean.h"
#include "math.h"


class TextShader {
private:
    float lineSpace = 0.f;

    GLProgram *shadowProgram;
    GLProgram *glProgram;
    TextGroup *currVaoGroup;
public:
    TextShader();

    ~TextShader();

    void Init();

    int FillVertex(TextInfo *&textInfo, ftgl::texture_font_t *font);

    int DrawStrokeNormalText(TextInfo *&textInfo, GLuint fontTexture);

    int DrawShadowText(TextInfo *&textInfo, GLuint fontTexture);

    void InitVertex(int textID);

    int DrawFrame(int frameIndex, TextInfo *&pInfo, GLuint fontTexture);

    void RemoveLayer(int layerId);

    /**
     * 应用当前文字组
     * @param layerId  层id
     * @return
     */
    int ApplyCurrentTextGroup(int layerId);

    VaoGroupManager *vaoGroupManager;

    void ClearVbo(int childId);
};


#endif //TESTFREETYPE_TEXT_SHADER_H
